/**
 * Created by Blink on 2017/8/24.
 * generate button style
 */
import colors from '../color';
import ColorHandle from 'color';
import {StyleSheet} from 'react-native';

export default () => {
    let r = {
        base: {
            borderRadius: 6,
            borderWidth: 1,
            paddingLeft: 12,
            paddingRight: 12,
            paddingTop: 6,
            paddingBottom: 6,

            flexDirection: 'row',
            justifyContent: 'center',
            alignItems: 'center'
        }
    };

    colors.forEach((v, k) => {
        let press = ColorHandle(v);
        const isLight = k.indexOf('light') >= 0;

        if (isLight) {
            press = press.darken(0.2).toString();
        } else {
            press = press.lighten(0.2).toString();
        }

        r[k] = {
            // ----- normal button style
            normal: {
                style: {
                    borderColor: v,
                    backgroundColor: v,
                },

                pressStyle: {
                    borderColor: press,
                    backgroundColor: press,
                },

                text: {
                    color: k === 'lightGrey' ? '#333': '#fff',
                }
            },
            // ----- basic button style
            basic: {
                style: {
                    borderColor: v,
                    backgroundColor: 'transparent'
                },

                pressStyle: {
                    borderColor: press
                },

                text: {
                    color: v
                },

                pressText: {
                    color: press
                }
            },

            // ----- inverted button style
            inverted: {
                style: {
                    borderColor: v,
                    backgroundColor: 'transparent',
                    borderWidth: 2
                },

                pressStyle: {
                    backgroundColor: v,
                },

                text: {
                    color: v,
                    fontWeight: 'bold'
                },

                pressText: {
                    color: '#fff'
                }
            },

            // ----- inverted basic button
            invertedBasic: {
                style: {
                    borderColor: 'rgba(255, 255, 255, .5)',
                    borderWidth: 2,
                    backgroundColor: 'transparent'
                },

                pressStyle: {
                    borderColor: v
                },

                text: {
                    color: '#fff',
                    fontWeight: 'bold'
                },

                pressText: {
                    color: v,
                }
            },
        };
    });

    return r;
}
